/*
 * G4SipmVoltageTraceModelTest.hh
 *
 * @created Apr 25, 2013
 * @author Tim Niggemann, III Phys. Inst. A, RWTH Aachen University
 * @copyright GNU General Public License v3.0
 */

#ifndef G4SIPMVOLTAGETRACEMODELTEST_HH_
#define G4SIPMVOLTAGETRACEMODELTEST_HH_

#include <gtest/gtest.h>
#include <CLHEP/Units/SystemOfUnits.h>

#include "model/impl/G4SipmGenericVoltageTraceModel.hh"

class G4SipmVoltageTraceModelTest: public testing::Test {
protected:
	const G4SipmVoltageTraceModel* testedObject;

	virtual void SetUp() {
		testedObject = new G4SipmGenericVoltageTraceModel;
	}
};

TEST_F(G4SipmVoltageTraceModelTest, pulse) {
	// Values calculated with Maple starting at t=0 in steps of dt=1.
	double v[] = { 0.0, 13.82349112, 23.14259770, 29.32228655, 33.31624320, 35.79073841, 37.21119094, 37.90266108,
			38.09212574, 37.93802186, 37.55089246, 37.00781476, 36.36248308, 35.65225503, 34.90307556, 34.13291800,
			33.35418872, 32.57540744, 31.80238147, 31.03902622, 30.28793842, 29.55079678, 28.82864180, 28.12207120,
			27.43137652, 26.75663840, 26.09779318, 25.45467928, 24.82706962, 24.21469410, 23.61725536, 23.03443970,
			22.46592453, 21.91138366, 21.37049084, 20.84292226, 20.32835808, 19.82648367, 19.33699018, 18.85957505,
			18.39394227, 17.93980245, 17.49687290, 17.06487760, 16.64354708, 16.23261840, 15.83183500, 15.44094656,
			15.05970890, 14.68788383, 14.32523902, 13.97154783, 13.62658924, 13.29014767, 12.96201284, 12.64197965,
			12.32984810, 12.02542310, 11.72851436, 11.43893632, 11.15650798, 10.88105283, 10.61239868, 10.35037762,
			10.09482590, 9.845583755, 9.602495425, 9.365408975, 9.134176205, 8.908652590, 8.688697175, 8.474172475,
			8.264944410, 8.060882205, 7.861858315, 7.667748340, 7.478430960, 7.293787845, 7.113703580, 6.938065610,
			6.766764160, 6.599692160, 6.436745180, 6.277821375, 6.122821415, 5.971648415, 5.824207890, 5.680407685,
			5.540157920, 5.403370930, 5.269961230, 5.139845420, 5.012942185, 4.889172202, 4.768458111, 4.650724460,
			4.535897664, 4.423905952, 4.314679325, 4.208149513, 4.104249931 };
	// Test
	for (unsigned int i = 0; i < 100; i++) {
		ASSERT_NEAR(v[i] * 1e-3 * CLHEP::volt, testedObject->pulse((double )i, 1.0), 0.001);
	}
}

#endif /* G4SIPMVOLTAGETRACEMODELTEST_HH_ */
